{extend name="index/public" /}

{block name="content"}
<form class="layui-form" action="" id="searchBox">
    <div class="layui-inline">
        <input type="text" name="my_user_id" value="" id="my_user_id" placeholder="米娱用户ID/米娱登录名称" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-inline">
        <input type="text" name="ch_user_id" value="" id="ch_user_id" placeholder="渠道用户ID/渠道登录名称" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-inline">
        <input type="text" name="phone_number" value="" id="phone_number" placeholder="手机号码" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-inline">
        <a href="javascript:;" class="layui-btn searchBtn my-btn my-btn-sm">搜索</a>
    </div>
</form>

<table id="tableBox" lay-filter="tableBox"></table>

<script type="text/html" id="tableBar">
    <a class="layui-btn layui-btn-green layui-btn-sm" lay-event="payRecord">充值记录</a>
    <a class="layui-btn layui-btn-normal layui-btn-sm"  lay-event="gameRecord">渠道绑定</a>
    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="modifyPwd">修改密码</a>
</script>
{/block}

{block name="css"}
{/block}

{block name="js"}
<script>
    layui.use('table', function(){
        var table = layui.table
            ,$ = layui.$
            ,form = layui.form
            ,load = null
            ,active = {
                reload: function () {
                    var jsonObj = {
                        "my_user_id": $('#my_user_id').val()
                        ,"phone_number": $('#phone_number').val()
                        ,"ch_user_id": $('#ch_user_id').val()
                    };

                    table.reload('tableId', {
                        page: {curr: 1}
                        ,where: jsonObj
                        ,height: 'full-100'
                    })
                },
            };

        //表格初始化
        table.render({
            elem: '#tableBox'
            ,height: 'full-100'
            ,url: '{:url("UserList/index")}'
            ,page: true
            ,limit:20
            ,limits:[20,40,60,80]
            ,loading:true
            ,id:'tableId'
            ,done: function () {
                layer.close(load);
                $('#layui-loading').hide();
            }
            ,cols: [[
                {field:'my_user_id', title: '米娱用户ID', width: 110}
                ,{field:'my_user_name', title: '登录名称', width: 150}
                ,{field:'plat', title: '注册平台', width: 90}
                ,{field:'reg_cps_id', title: '渠道ID', width: 90}
                ,{field:'reg_cps_name', title: '注册渠道', width: 140}
                ,{field:'reg_game_id', title: '游戏ID', width: 90}
                ,{field:'reg_game_name', title: '注册游戏', width: 140}
                ,{field:'reg_time', title: '注册时间', width: 160}
                ,{field:'phone_number', title: '手机号码', width: 120}
                ,{field:'reg_type', title: '注册类型', width: 90}
                ,{field:'last_login_time', title: '最后登录时间', width: 160}
                ,{field:'ch_user_id', title: '渠道用户ID', width: 130}
                ,{field:'ch_user_name', title: '渠道用户名', width: 130}
                ,{field:'cp_user_id', title: 'CP用户ID', width: 130}
                ,{title: '操作', width: 300, align:'center', toolbar:'#tableBar', fixed: 'right'}
            ]]
        });

        $('#searchBox .searchBtn').on('click', function(){
            load = layer.load();
            active['reload'].call(this);
            return false;
        });

        //监听工具条
        table.on('tool(tableBox)', function(obj){
            var data = obj.data;

            if(obj.event === 'payRecord'){
                layer.open({
                    type: 2
                    ,title: '充值记录'
                    ,resize: true
                    ,offset: '80px'
                    ,area: ['1200px', '700px']
                    ,content: '{:url("UserList/pay")}?my_user_id='+data.my_user_id+'&channel_id='+data.channel_id
                });
            }else if(obj.event === 'gameRecord'){
                layer.open({
                    type: 2
                    ,title: '渠道游戏绑定'
                    ,resize: true
                    ,offset: '80px'
                    ,area: ['1200px', '700px']
                    ,content: '{:url("UserList/game")}?my_user_id='+data.my_user_id+'&my_user_name='+data.my_user_name
                });
            }else if(obj.event === 'modifyPwd'){
                layer.open({
                    type: 2
                    ,title: '修改密码'
                    ,resize: true
                    ,area: ['1000px', '650px']
                    ,offset: '100px'
                    ,content: '{:url("UserList/pwd")}?my_user_id='+data.my_user_id
                });
            }
        });
    });
</script>
{/block}